import request from "@/utils/request.ts"

// 获取菜单树
export function getMenuTree() {
    return request({
        url: "/api/menu",
        method: 'get'
    })
}

/**
 * 新增-更新菜单节点
 * @param menuId
 * @param name
 * @param parentMenuId
 * @param nowPath
 * @param iconTag
 * @param menuOrder
 */
export function addOrUpdateMenuTree(menuId: string | null, name: string, parentMenuId: string, nowPath: string, iconTag: string, menuOrder: number | null) {
    return request({
        url: "/api/menu/upsert",
        method: 'post',
        data: {menuId, name, parentMenuId, nowPath, iconTag, menuOrder}
    })
}

// 删除菜单节点
export function delMenu(menuId: string) {
    return request({
        url: `/api/menu/${menuId}`,
        method: 'delete'
    })
}
